package com.bawei.lizhiyu1228.mvp;

import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * @author : zhiyu
 * @date : 2021/12/28
 * @content :
 */
public class MyManager {
    private static MyManager myManager;
    public static MyManager getInstance(){
        if (myManager==null){
            synchronized (MyManager.class){
                myManager=new MyManager();
            }
        }

        return myManager;
    }

    private Retrofit retrofit;
    public Retrofit getRetrofit(){
        if (retrofit==null){
            retrofit=new Retrofit.Builder()
                    .client(new OkHttpClient().newBuilder().build())
                    .baseUrl("http://www.qubaobei.com")
                    .addConverterFactory(GsonConverterFactory.create())
                    .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                    .build();
        }
        return retrofit;
    }
}
